package com.kai.mqtt.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author weijk
 * @since 2024/8/16
 */
public class LoginLocalUtil {

    private final static ThreadLocal<Map<String, String>> threadLocal = ThreadLocal.withInitial(HashMap::new);

    public static void clear() {
        threadLocal.remove();
    }

    public static String getToken() {
        Map<String, String> map = threadLocal.get();
        return map.get("accessToken");
    }

    public static void setToken(String accessToken) {
        Map<String, String> map = threadLocal.get();
        map.put("accessToken", accessToken);
    }
}
